package com.homework.ch10;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/11
 * @Description:
 */

//请编写一个Java程序，创建两个线程，一个打印50以内的奇数，另一个打印50以内的偶数。
public class Test {
    public static void main(String[] args) {
        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < 50; i+=2) {
                    System.out.println(Thread.currentThread().getName()+" : "+i);
                }
            }
        },"线程1");
        Thread t2=new Thread("线程2"){
            @Override
            public void run(){
                for (int i = 0; i <=50; i+=2) {
                    System.out.println(Thread.currentThread().getName()+" : "+i);
                }
            }
        };
        t1.start();
        t2.start();
    }
}
